package com.itfreer.data.check.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;

import com.itfreer.form.api.entity.EntityBase;
import com.itfreer.form.api.reflect.DictionaryListField;

/**
 * 数据检查结果
 */
@Entity(name = "data_check_history")
public class CheckHistoryEntity extends EntityBase implements Serializable {

	private static final long serialVersionUID = -1586471105523897157L;

	/**
	 * 主键
	 */
	@Id
	@Column(name = "id", length = 50)
	private String id;

	/**
	 * 检查名称
	 */
	@Column(name = "s_name", length = 50, nullable = false)
	private String name;

	/**
	 * 检查数据 可能是单一检查数据的主键，也可能是批量检测的ID
	 */
	@Column(name = "s_dataid", length = 50, nullable = true)
	private String dataid;

	/**
	 * 成功状态
	 */
	@Column(name = "b_state", nullable = true)
	private Boolean state;

	/**
	 * 最后检测时间
	 */
	@Column(name = "d_lastTime", nullable = true)
	private Date lastTime;

	/**
	 * 备注
	 */
	@Column(name = "s_info", length = 200, nullable = true)
	private String info;

	/**
	 * 检查类型，用于区分数据 如，数据导入等
	 */
	@Column(name = "s_type", length = 10, nullable = true)
	private String type;

	/**
	 * 详细配置信息
	 */
	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
	@JoinColumn(name = "s_hid")
	@OrderBy("i_order ASC")
	@DictionaryListField
	private Set<CheckHistoryItemEntity> items = new LinkedHashSet<>();

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getDataid() {
		return dataid;
	}

	public void setDataid(String dataid) {
		this.dataid = dataid;
	}

	public Boolean getState() {
		return state;
	}

	public void setState(Boolean state) {
		this.state = state;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Date getLastTime() {
		return lastTime;
	}

	public void setLastTime(Date lastTime) {
		this.lastTime = lastTime;
	}

	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Set<CheckHistoryItemEntity> getItems() {
		return items;
	}

	public void setItems(Set<CheckHistoryItemEntity> items) {
		this.items = items;
	}
}
